#include <stdio.h>

int main()
{
    FILE *file = fopen("merged.txt", "r");
    if (file == NULL)
    {
        printf("无法打开文件\n");
        return 1;
    }
    //  字符数          单词数         行数
    int charCount = 0, wordCount = 0, lineCount = 0;
    int inWord = 0;
    char ch;

    while ((ch = fgetc(file)) != EOF)
    {
        charCount++;

        if (ch == ' ' || ch == '\t' || ch == '\n')
        {
            inWord = 0;
        }
        else if (!inWord)
        {
            wordCount++;
            inWord = 1;
        }

        if (ch == '\n')
        {
            lineCount++;
        }
    }

    fclose(file);

    printf("字符数： %dn", charCount);
    printf("单词数： %d\n", wordCount);
    printf("行数： %d\n", lineCount);

    return 0;
}
